import { App, defineAsyncComponent } from "vue";
const components = import.meta.glob("./globals/**/*.vue"); // 异步方式
export default function install(app: App): void {
  let GlobalsComponents:string[] = []
  for (const [key, value] of Object.entries(components)) {
    let name = key.slice(key.lastIndexOf("/") + 1, key.lastIndexOf("."));
    GlobalsComponents.push(name)
    name = name
      .replace(/([A-Z])/g, "-$1")
      .toLowerCase()
      .slice(1);
    app.component(name, defineAsyncComponent(value as any));
  }

  console.log(
    `%c全局已注册组件:${GlobalsComponents.join(",")}`,
    "color: #FF6A00"
);
}
 